/**
* MinimaxNode.java
* @author J.T. Gralka <gralkajt@washjeff.edu>, Topher Witt <wittcm19@uww.edu>
* @version 06/15/11
*
* Stores information as a node value for the Minimax JHAVE visualization.
*/

import java.util.ArrayList;

public class MinimaxNode{		
	// iVars	
	private MinimaxNode nextSibling; // references the node's next sibling for MinimaxNodeList implementation
	private ArrayList<MinimaxNode> children; // references a MinimaxNodeList of the current node's children
	private int value; // the current utility value of the node
	private boolean isMax; // is the node a MAX node?
	private boolean isLeaf; // is the node a leaf?

	// Constructor
	public MinimaxNode(MinimaxNode nextSibling, boolean isMax, int value,
			boolean isLeaf){
		this.nextSibling = nextSibling;
		this.isMax = isMax;		
		this.value = value;
		this.isLeaf = isLeaf;
		children = new ArrayList<MinimaxNode>();
	}

	public MinimaxNode(boolean isMax, int value){
		this(null, isMax, value, false);
	}

	public MinimaxNode(int value){
		this(true, value);
	}

	public MinimaxNode(){
		this(-1);
	}

	// Accessors
	public MinimaxNode getNext(){
		return nextSibling;
	}

	public int getValue(){
		return value;
	}

	public boolean isMax(){
		return isMax;
	}

	public ArrayList<MinimaxNode> getChildren(){
		return children;
	}

	public boolean isLeaf(){
		return isLeaf;
	}

	// Mutators
	public void setNext(MinimaxNode nextSibling){
		this.nextSibling = nextSibling;
	}

	public void setValue(int value){
		this.value = value;
	}

	public void setIsMax(boolean isMax){
		this.isMax = isMax;
	}

	public void setChildren(ArrayList<MinimaxNode> children){
		this.children = children;
	}
	
	public void setIsLeaf(boolean isLeaf){
		this.isLeaf = isLeaf;
	}

	// Helper methods
	public String toString(){
		return (isMax?"MAX":"MIN") + " node: ("+value+")";
	}
}
